<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 1.0, user-scalable = no"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="keywords" content="" /> 
<meta name="description" content="" />
<title>支付</title>
<link type="text/css" href="css/reset.css" rel="stylesheet" />
<link type="text/css" href="css/public.css" rel="stylesheet" />
<link type="text/css" href="css/wode.css" rel="stylesheet" />
<script>
    var deviceWidth = Math.min(640, window.innerWidth)
    document.documentElement.style.fontSize = deviceWidth / 7.5 + "px"
</script>
 <script src="js/jquery.min.js?v=2.1.4"></script>
 <script src="js/core.js"></script>
</head>
<body style="background: #FFFFFF;">
<!-- top -->

<div class="header">
    <header class="p_header public-red">
        <a href="javascript:history.go(-1);" class="p_header_left">
            <i class="p_left" title="返回"></i>
        </a>
        <h1 class="p_dizhi">支付</h1>
    </header>
</div>
<!--设置支付密码-->

    <div class="a_main">
        <h2>请输入交易密码</h2>
        <div class="pwd-box">  
            <input type="tel" maxlength="6" class="pwd-input" id="pwd-input">  
            <div class="fake-box">  
                <input type="password" id="password1" readonly>  
                <input type="password" id="password2" readonly>  
                <input type="password" id="password3" readonly>  
                <input type="password" id="password4" readonly>  
                <input type="password" id="password5" readonly>  
                <input type="password" id="password6" readonly>  
            </div>  
        </div> 
    </div>
        <input type="button" class="p_button" onclick="xiugaisss()" value="确认支付">


<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
	var $input = $(".fake-box input");  
	var pwd="";
        $("#pwd-input").on("input", function() {  
            pwd = $(this).val().trim();  
            for (var i = 0, len = pwd.length; i < len; i++) {  
                $input.eq("" + i + "").val(pwd[i]);  
            }  
            $input.each(function() {  
                var index = $(this).index();  
                if (index >= len) {  
                    $(this).val("");  
                }  
            });  
            if (len == 6) {  
                //执行其他操作  
                //alert(pwd);
              //  xiayibu(pwd);
                
            }  
        }); 
        function  xiugaisss(){
        	 if(pwd.length==6){
					   $.ajax({ 
							url: urlcore + "/api/user/setthepassword3?password="+pwd+"&userId="+uuuuid,
							type: "get",
							dataType: 'json',
							contentType: "application/json;charset=utf-8",
							success: function(data) {
								if(data.success == true) {
										if(getvl("jiana")!=""){
												if(sessionStorage.getItem("qian")!="" &&sessionStorage.getItem("qian")!=null){
														sessionStorage.setItem("orids","");
														sessionStorage.setItem("chengxin","");
														sessionStorage.setItem("hid","");
														yuezhifu3();
												}
										}else{
												if(sessionStorage.getItem("orids")!="" && sessionStorage.getItem("orids")!=null){
														sessionStorage.setItem("chengxin","");
														sessionStorage.setItem("hid","");
														yuezhifu();
														
												}else if(sessionStorage.getItem("hid")!="" && sessionStorage.getItem("hid")!=null || sessionStorage.getItem("tid")!="" && sessionStorage.getItem("tid")!=null){
														console.log(2)
														yuezhifu2();
														sessionStorage.setItem("orids","");
														sessionStorage.setItem("chengxin","");
												}else if(sessionStorage.getItem("chengxin")!="" &&sessionStorage.getItem("chengxin")!=null ){
													console.log(3)
														yuezhifu4();
														sessionStorage.setItem("orids","");
														sessionStorage.setItem("hid","");
												}else if(sessionStorage.getItem("useridss")!=null&& sessionStorage.getItem("useridss")!="" && sessionStorage.getItem("oderidsoderids")!="" && sessionStorage.getItem("oderidsoderids")!=null){
														console.log(4)
														sessionStorage.setItem("orids","");
														sessionStorage.setItem("hid","");
														sessionStorage.setItem("chengxin","");
														odergoodss();
												}
										}
								} else {
									alert("密码不匹配");
								}
						},
						error: function() {
							alert("error");
						}
					});
					 }else{
								alert("密码未输入完整");
					 }
        }

//余额支付会员
function yuezhifu2(){
		var url2="";
		if(sessionStorage.getItem("hid")!=null&& sessionStorage.getItem("hid")!=""){
	     url2="/api/pay/balanceMoney2?memberId="+sessionStorage.getItem("hid")+"&userId="+uuuuid;
		}else if(sessionStorage.getItem("tid")!=null && sessionStorage.getItem("tid")!=""){
	     url2="/api/pay/balanceMoney2?incrementServiceId="+sessionStorage.getItem("tid")+"&userId="+uuuuid;		
		}else{
			alert("支付失效");
			window.location.href="buy/12.0.0buy_wode.html";
		}
    if(url2!=""){
			console.log(url2)
			$.ajax({
				url: urlcore+url2,
				type: "get",
				dataType: 'json',
				contentType: "application/json;charset=utf-8",
				success: function(data) {
					if(data.success == true) {
						alert("支付成功");
					window.location.href="buy/12.0.0buy_wode.html";
					}else{
						alert("支付失败");
					window.location.href="buy/12.0.0buy_wode.html";
					}
				},
				error: function() {
					/* Act on the event */
					alert("error");
				}
			});
	}
}


        //诚信
function yuezhifu4(){
		if(sessionStorage.getItem("chengxin")==""){
			alert("支付超时");
			 window.history.back(-1);  
		}else{
			
	$.ajax({
		url: urlcore+"/api/pay/balanceMoney2?isPayThaw=1&cashMoney="+sessionStorage.getItem("chengxin")+"&userId="+uuuuid,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
					alert("支付成功");
				//window.history.back(-2); 
		     window.location.href="buy/12.0.0buy_wode.html";
			}else{
				alert("支付失败");
					 window.history.back(-1);  
			//window.location.href="buy/12.0.0buy_wode.html";
			}
		},
		error: function() {
			/* Act on the event */
			alert("error");
		}
	});
		}
}


        //余额支付开店押金
function yuezhifu3(){
		if(sessionStorage.getItem("qian")==""){
			alert("支付超时");
			 window.history.back(-1);  
		}else{
			/*alert(sessionStorage.getItem("qian"))*/
	$.ajax({
		url: urlcore+"/api/pay/balanceMoney2?recoedType=2&cashMoney="+sessionStorage.getItem("qian")+"&userId="+uuuuid,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
					alert("支付成功");
			window.location.href="buy/12.0.0buy_wode.html";
			}else{
				alert("支付失败");
			 window.history.back(-1);  
			//window.location.href="buy/12.0.0buy_wode.html";
			}
		},
		error: function() {
			/* Act on the event */
			alert("error");
		}
	});
		}
}
function yuezhifu(){
		var url2="";
		if(sessionStorage.getItem("orids")!=null&& sessionStorage.getItem("orids")!="" && uuuuid!=""){
	      url2="/api/pay/balanceMoney2?userId="+uuuuid+"&orderId="+sessionStorage.getItem("orids");
		}else{
			alert("交易信息失效");
				window.location.href="buy/12.0.0buy_wode.html";
		}
		if(url2!=""){
				$.ajax({
					url: urlcore+url2,
					type: "get",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					success: function(data) {
						if(data.success == true) {
							//alert("支付成功");
								alert("支付成功");
							window.location.href="buy/12.0.0buy_wode.html";
						}else{
							alert(data.msg);
						}
					},
					error: function() {
						/* Act on the event */
						alert("error");
					}
				});
	  }
}

		 function odergoodss(){
		var url2="";
		if(sessionStorage.getItem("useridss")!=null&& sessionStorage.getItem("useridss")!="" && sessionStorage.getItem("oderidsoderids")!="" && sessionStorage.getItem("oderidsoderids")!=null){
	url2="/api/pay/balanceMoney2?userId="+sessionStorage.getItem("useridss")+"&orderId="+sessionStorage.getItem("oderidsoderids");
		}else{
			alert("请求超时");
			 window.history.back(-1);  
      }
      if(url2!=""){
	$.ajax({
		url: urlcore+url2,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
					 chenggong(sessionStorage.getItem("oderidsoderids"));
			}else{
				  //  alert("支付失败");
				  chenggong2(sessionStorage.getItem("oderidsoderids"));
					//window.location.href="../gotoindex.html";
			}
		},
		error: function() {
			/* Act on the event */
			alert("error");
		}
	});
	}
}
		 
		 
		 
		 
		 
function chenggong2(oderid){
	$.ajax({
		url: urlcore+"/api/goodsCar/guestlist?oderid="+oderid,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
			alert("支付失败");
			window.location.href="../gotoindex.html";
			}
		},
		error: function() {
			/* Act on the event */
			//alert("error");
		}
	});
}
		 
		 
function chenggong(oderid){
	$.ajax({
		url: urlcore+"/api/goodsCar/guestlist?oderid="+oderid,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
			alert("支付成功");
			window.location.href="../gotoindex.html";
			}
		},
		error: function() {
			/* Act on the event */
			//alert("error");
		}
	});
}
</script>
</body>
</html>